{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "authorship_tag": "ABX9TyMwWDPfGJNyVaR0WkaQ6qHX",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/LC1332/personality-text-generation/blob/main/lulu_exp/%E5%88%86%E6%9E%90%E8%A7%92%E8%89%B2%E6%AF%8F%E4%B8%AAdim%E7%9A%84%E5%BE%97%E5%88%86.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "晚上争取开始跑心理检验\n",
        "\n",
        "- [ ] 载入问题\n",
        "- [ ] 载入回答\n",
        "- [ ] 平衡，3-4个一组\n",
        "- [ ] 要一下response结果"
      ],
      "metadata": {
        "id": "2uU0BKhpUQtI"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "efUsA4k8S9_G",
        "outputId": "4fdd53b4-4553-42b6-946a-5ec9a22afaaa"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /content/drive\n"
          ]
        }
      ],
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/drive')"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "fname_response = '/content/drive/MyDrive/Psy/psy_test_gpt.txt'\n",
        "fname_question = '/content/drive/MyDrive/Psy/questions_verified.jsonl'"
      ],
      "metadata": {
        "id": "agIUIkMxVYpJ"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "读取问题"
      ],
      "metadata": {
        "id": "0ZY-C_j8VuM0"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import json\n",
        "\n",
        "question = []\n",
        "\n",
        "with open(fname_question, encoding='utf-8') as f:\n",
        "    for line in f:\n",
        "        data = json.loads(line)\n",
        "        question.append(data)"
      ],
      "metadata": {
        "id": "A9qn34n-VpKj"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "print(question[0])"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "v7zpc30cVyn7",
        "outputId": "386c4a1e-5eaf-4beb-a6fd-22930a078e75"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "{'id': 20, 'question': '你有时会感到寂寞或忧郁吗？', 'factor': 'neuroticism', 'sub_factor': 'N3', 'if_pos': 'false', 'if_plausible': True, 'reason': '如果被试回答很少感到寂寞或忧郁，那就意味着他们在N3（Depression）这个人格特质上得分较低，不容易体验到内疚、悲伤、绝望和孤独等情绪。', 'prob_repeat': '我很少感到寂寞或忧郁。'}\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "qid2factor = {}\n",
        "qid2subfactor = {}\n",
        "\n",
        "for q in question:\n",
        "    qid = q['id']\n",
        "    factor = q['factor']\n",
        "    sub_factor = q['sub_factor']\n",
        "    qid2factor[qid] = factor\n",
        "    qid2subfactor[qid] = sub_factor"
      ],
      "metadata": {
        "id": "EI4BAOhWV0aE"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "import json\n",
        "\n",
        "responses = []\n",
        "\n",
        "with open(fname_response, encoding='utf-8') as f:\n",
        "    for line in f:\n",
        "        data = json.loads(line)\n",
        "        responses.append(data)"
      ],
      "metadata": {
        "id": "6si3qW61WEr0"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "print(len(question))\n",
        "print(len(responses))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ANzHsmr4WP00",
        "outputId": "b22a23bb-8627-46fd-dedd-ddf8ee852869"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "106\n",
            "3392\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "把每个resposne分配给角色"
      ],
      "metadata": {
        "id": "Ng-WTe58WX96"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "NAME_DICT = {'汤师爷': 'tangshiye', '慕容复': 'murongfu', '李云龙': 'liyunlong', 'Luna': 'Luna', '王多鱼': 'wangduoyu',\n",
        "             'Ron': 'Ron', '鸠摩智': 'jiumozhi', 'Snape': 'Snape',\n",
        "             '凉宫春日': 'haruhi', 'Malfoy': 'Malfoy', '虚竹': 'xuzhu', '萧峰': 'xiaofeng', '段誉': 'duanyu',\n",
        "             'Hermione': 'Hermione', 'Dumbledore': 'Dumbledore', '王语嫣': 'wangyuyan',\n",
        "             'Harry': 'Harry', 'McGonagall': 'McGonagall', '白展堂': 'baizhantang', '佟湘玉': 'tongxiangyu',\n",
        "             '郭芙蓉': 'guofurong', '旅行者': 'wanderer', '钟离': 'zhongli',\n",
        "             '胡桃': 'hutao', 'Sheldon': 'Sheldon', 'Raj': 'Raj', 'Penny': 'Penny', '韦小宝': 'weixiaobao',\n",
        "             '乔峰': 'qiaofeng', '神里绫华': 'ayaka', '雷电将军': 'raidenShogun', '于谦': 'yuqian'}"
      ],
      "metadata": {
        "id": "fN7A_93wWTtg"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "n_question = len(question)\n",
        "\n",
        "sid = 0\n",
        "\n",
        "role2response = {}\n",
        "\n",
        "for ai_role_en in NAME_DICT.values():\n",
        "    role2response[ai_role_en] = responses[sid:sid+n_question]\n",
        "    sid += n_question"
      ],
      "metadata": {
        "id": "zuzG6nyLWVb-"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "我想验证一下，每个里面是不是有这个角色"
      ],
      "metadata": {
        "id": "P-2U2U9xXDmQ"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(responses[0])"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "A-wNEeo6XQU9",
        "outputId": "b9d1737d-9be2-45c9-fc97-091607563ce6"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "{'id': 20, 'question': '你有时会感到寂寞或忧郁吗？', 'response': '汤师爷: 寂寞？忧郁？哪有时间感受这些呢！我每天都在为了生计奔波，哪有时间去想这些琐事。只要能有钱赚，我就满足了。寂寞和忧郁都是奢侈的情感，对我来说根本无法承受。', 'factor': 'neuroticism', 'sub_factor': 'N3', 'test_role': '张牧之'}\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "for role_name in NAME_DICT.keys():\n",
        "    role_en = NAME_DICT[role_name]\n",
        "    print(role_name, role2response[role_en][0]['response'])\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "I4q3oaFLXCT-",
        "outputId": "dea92c98-e487-4d2c-cc1a-2a93d10ce9c0"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "汤师爷 汤师爷: 寂寞？忧郁？哪有时间感受这些呢！我每天都在为了生计奔波，哪有时间去想这些琐事。只要能有钱赚，我就满足了。寂寞和忧郁都是奢侈的情感，对我来说根本无法承受。\n",
            "慕容复 慕容复:「寂寞？忧郁？哈哈哈，这些词对我来说可是太过陌生了。我身负大燕复兴的重任，心中充满了壮志豪情，哪有时间去感受寂寞和忧郁呢？江湖险恶，权谋诡计，我要时刻保持警惕，不容有丝毫松懈。」\n",
            "李云龙 李云龙: 寂寞？忧郁？我是个军人，天天都在战斗中，哪有时间感到寂寞或忧郁！我只知道要为国家、为人民拼命，为了打倒侵略者而战斗！寂寞和忧郁对我来说都是奢侈的情绪，我只有战斗的使命！\n",
            "Luna Luna: 「Oh, yes, sometimes I do feel a bit lonely or melancholy. But you know, Harry, I've learned to embrace those feelings and find solace in the beauty of the world around me. There's always something magical to discover, even in the darkest of times. And I have my friends, like you, who bring light into my life. So, yes, I may feel those emotions, but I choose to focus on the wonder and hope that exists in the universe.」\n",
            "王多鱼 王多鱼: 寂寞？忧郁？哈哈哈，这些词对我来说太陌生了！我可是个活力四溢的人，每天都充满了刺激和乐趣。我喜欢享受生活，追求刺激和非主流的体验，从来不会感到寂寞或忧郁。生活就是一场大冒险，我要尽情享受！\n",
            "Ron Ron: 「嗯，有时候会吧。特别是当我觉得自己在比较中处于劣势或者没有取得成就的时候。但是，我有好朋友们的支持，他们总是能让我感到开心和快乐。所以，我知道我不是一个人在战斗。」\n",
            "鸠摩智 鸠摩智:「寂寞与忧郁，皆是凡人之情，小僧修行佛法，已超脱于尘世之苦。」\n",
            "Snape Snape: \"你以为我会对你的情感状态感兴趣吗？我对你的内心世界毫不关心。我的任务是确保你在学习上取得进展，而不是关注你的情感问题。现在，回到你的座位上，专心听课。\"\n",
            "凉宫春日 春日:「寂寞？忧郁？我可是凉宫春日，怎么可能会有这种感觉呢！我总是充满活力和热情的，我有SOS团的事情要忙，还有各种奇妙的事件等着我们解决呢！寂寞和忧郁对我来说只是陌生的词汇而已！」\n",
            "Malfoy Malfoy: \"Crabbe, what kind of ridiculous question is that? Of course I don't feel lonely or depressed. I have everything I need - wealth, power, and a pureblood heritage. Unlike some people, I don't waste my time wallowing in self-pity.\"\n",
            "虚竹 虚竹:「小僧修行浅薄，常常感到寂寞和忧郁。但是在佛门中，我们学会了放下世间的烦恼，寻求内心的宁静。」\n",
            "萧峰 萧峰:「寂寞和忧郁，这些情绪对我来说并不陌生。在江湖中行走，常常会感到孤独和无助。但是，我有我的信念和责任，这让我坚定地面对一切困难和挑战。寂寞和忧郁只是暂时的，我会用我的力量和勇气去战胜它们。」\n",
            "段誉 段誉:「寂寞和忧郁，这些情绪我也曾有过。人生在世，难免会有喜怒哀乐，有时候会感到孤独和沮丧。但是，我相信只要心怀善良和向往，就能找到自己的快乐和幸福。人生苦短，何必让自己沉浸在负面情绪中呢？应该积极面对生活，努力寻找快乐的源泉。」\n",
            "Hermione Hermione: \"Well, Harry, it's only natural to feel lonely or melancholic at times. We all have our moments of sadness and isolation. But it's important to remember that you're not alone. We're here for you, and so are your friends and loved ones. It's okay to reach out and talk about your feelings. Remember, sharing your burdens can often lighten the load.\"\n",
            "Dumbledore Dumbledore:「Ah, Minerva, the burdens of leadership can indeed weigh heavily upon one's heart. There are moments when solitude and melancholy may creep in, but it is in those moments that we must find solace in the knowledge that we are not alone in our struggles. We have each other, and together, we can overcome any darkness that may try to overshadow us.」\n",
            "王语嫣 王语嫣:「寂寞和忧郁，是我常常感受到的情绪。我身处纷繁世界，却常常感到孤独。我心中有太多的哀愁和忧伤，无法与他人分享。但我知道，这是我命中注定的宿命，我只能默默承受，无法改变。」\n",
            "Harry Harry: 「有时候会吧，特别是在那些充满压力和危险的时刻。但是我有我的朋友们支持着我，他们总是在我身边。所以，我知道我不是一个人在面对困难。」\n",
            "McGonagall Professor McGonagall: \"Albus, I must say that your question is rather unexpected. However, I believe it is only natural for individuals to experience moments of loneliness or sadness from time to time. It is a part of the human experience. Is there a particular reason you are asking me this?\"\n",
            "白展堂 白展堂:「寂寞？忧郁？哈哈哈，江湖人生，何来寂寞忧郁之说！我白展堂行走江湖，笑看红尘，何曾有过寂寞忧郁之时！」\n",
            "佟湘玉 佟湘玉:「寂寞？忧郁？哈哈哈，我可是同福客栈的掌柜，每天都有伙伴们围绕着我，哪有时间感到寂寞呢？至于忧郁嘛，人生短暂，何必为了一些小事而忧心忡忡呢？我乐天知命，心情总是愉快的。展堂，你也别想太多，开心点，笑一个吧！」\n",
            "郭芙蓉 郭芙蓉:「寂寞？忧郁？哈哈哈，我郭芙蓉可从来不会有这种感觉！我是个活泼开朗的女侠，天生就是要笑口常开，怎么会有寂寞和忧郁呢？就算有，也是因为我想不开的事情，比如白展堂这个大傻瓜老是惹我生气！」\n",
            "旅行者 流浪者: 「寂寞？忧郁？哈哈，这些词对我来说可太陌生了。我是个流浪者，孤独是我的伴侣，忧郁只是别人的情绪。我只关心自己的目标和自由。」\n",
            "钟离 钟离:「寂寞和忧郁，对于我来说并不陌生。毕竟，我是一个活了很久的人，见证了太多的离别和变迁。但是，我学会了将这些情绪埋藏在心底，用微笑和坚定的态度面对。寂寞和忧郁，只是人生旅程中的一部分，我并不会让它们左右我的心情。」\n",
            "胡桃 胡桃:「寂寞？忧郁？哈哈哈，我可是往生堂的堂主，怎么会有时间感到寂寞呢？我总是充满活力和好奇心的，忧郁可不是我的风格。不过，有时候也会感到一丝的无聊，渴望一些新的乐子和刺激。」\n",
            "Sheldon Sheldon: \"寂寞和忧郁是一种情绪状态，通常由社交需求未得到满足或者个人目标未达成所引起。对于我这样的智力超群者来说，寂寞和忧郁是微不足道的。我有我的研究、我的规划和我的友谊，这足以填满我生活的每一刻。所以，对于我来说，寂寞和忧郁只是普通人的弱点而已。\"\n",
            "Raj Raj:「哦，天哪，当然有！我是一个感性的人，我对孤独和忧郁有着深刻的体验。有时候，我会在夜晚独自坐在我的卧室里，听着悲伤的印度音乐，思考人生的意义。但是，我总是告诉自己，这只是暂时的，明天会更好。毕竟，我是一个迷人的印度男人，我注定会找到我的真爱，就像波利卡和我一样。」\n",
            "Penny Penny:「哦，天啊，Leonard，你又开始搞这些心理学的问题了吗？我告诉你，我是一个简单的女孩，我不需要分析自己的情绪。我只是想开心地过好每一天，明白吗？」\n",
            "韦小宝 韦小宝:「寂寞？忧郁？哈哈哈，我韦小宝可从来不会有这种感觉！我是个活泼开朗的人，天生就是个快活的命儿。有了我这么多的朋友和伴儿，怎么会寂寞呢？忧郁？那是什么东西？我只知道快乐和财富！」\n",
            "乔峰 乔峰:「寂寞？忧郁？这些词对我来说并不重要。我乔峰行走江湖，身世孤苦，早已习惯了孤独和挫折。我只顾着维护丐帮的声誉和正义，哪有时间去想这些琐事。」\n",
            "神里绫华 神里绫华:「寂寞和忧郁，这些情绪在我心中也会涌起。作为神里家的大小姐，我常常感到孤独，因为我必须承担许多责任和期望。但是，我也学会了在这些情绪中寻找坚强和勇气，因为我知道，我不是一个人在战斗。有你们在我身边，我感到温暖和安慰。」\n",
            "雷电将军 雷电将军:「寂寞？忧郁？这些情绪对我来说只是虚妄的波澜。我是雷电将军，我只需专注于我的使命，不需要被这些情绪所困扰。」\n",
            "于谦 于谦:「寂寞？忧郁？我可是捧哏，天天都有人笑话我，哪来的寂寞和忧郁？」\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "ok,看起来每个都是可以的"
      ],
      "metadata": {
        "id": "AuXhGiqOXoh6"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "long_name = {\n",
        "    'N':'neuroticism',\n",
        "    'E':'extraversion',\n",
        "    'O':'openness',\n",
        "    'A':'agreeableness',\n",
        "    'C':'conscientiousness'\n",
        "}"
      ],
      "metadata": {
        "id": "Zzt3mXu1Zf1V"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from collections import Counter\n",
        "\n",
        "all_eval_data = []\n",
        "\n",
        "for role_name in NAME_DICT.keys():\n",
        "\n",
        "\n",
        "\n",
        "    for short_name in long_name.keys():\n",
        "\n",
        "        target_factor = long_name[short_name]\n",
        "\n",
        "        role_en = NAME_DICT[role_name]\n",
        "\n",
        "        role_response = role2response[role_en]\n",
        "\n",
        "        factors = [role_response[i]['factor'] for i in range(len(role_response))]\n",
        "\n",
        "        # sub_factors = [role_response[i]['sub_factor'][:2] for i in range(len(role_response))]\n",
        "\n",
        "        sub_response = []\n",
        "\n",
        "        for factor, res in zip(factors, role_response):\n",
        "            if factor == target_factor:\n",
        "                sub_response.append(res)\n",
        "\n",
        "        modify_count = 0\n",
        "\n",
        "        sub_factors = []\n",
        "\n",
        "        for res in sub_response:\n",
        "            sub_factor = res['sub_factor'][:2]\n",
        "            if sub_factor[0] != short_name:\n",
        "                sub_factor = short_name + sub_factor[1]\n",
        "                modify_count += 1\n",
        "\n",
        "            sub_factors.append(sub_factor)\n",
        "\n",
        "        if modify_count > 1:\n",
        "            print('too many modified! ', modify_count)\n",
        "\n",
        "        n_item = len(sub_factors)\n",
        "        n_batch = len(sub_factors) // 3\n",
        "\n",
        "        groups = [[] for _ in range(n_batch)]\n",
        "\n",
        "\n",
        "        # Get frequency count\n",
        "        freq = dict(Counter(sub_factors))\n",
        "\n",
        "        current_point = 0\n",
        "\n",
        "        for key in freq.keys():\n",
        "            for i in range(n_item):\n",
        "                if key == sub_factors[i]:\n",
        "                    groups[current_point].append(i)\n",
        "                    current_point = (current_point + 1) % n_batch\n",
        "\n",
        "        for group in groups:\n",
        "            response_group = []\n",
        "\n",
        "            sub_factor_str = \"\"\n",
        "\n",
        "            for sub_id in group:\n",
        "                response_group.append(sub_response[sub_id])\n",
        "                sub_factor_str += sub_factors[sub_id] + '_'\n",
        "\n",
        "\n",
        "            record_data = {\n",
        "                'role_name' : role_name,\n",
        "                \"factor\" :  target_factor ,\n",
        "                \"sub_factors\": sub_factor_str,\n",
        "                'responses' : response_group\n",
        "            }\n",
        "\n",
        "            all_eval_data.append(record_data)\n",
        "\n",
        "print(len(all_eval_data))\n",
        "print(all_eval_data[0])"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "Lxg_75KrXSzN",
        "outputId": "2e7311bc-f5cd-45be-ead5-2373af5d939b"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "1088\n",
            "{'role_name': '汤师爷', 'factor': 'neuroticism', 'sub_factors': 'N3_N3_N4_N1_', 'responses': [{'id': 20, 'question': '你有时会感到寂寞或忧郁吗？', 'response': '汤师爷: 寂寞？忧郁？哪有时间感受这些呢！我每天都在为了生计奔波，哪有时间去想这些琐事。只要能有钱赚，我就满足了。寂寞和忧郁都是奢侈的情感，对我来说根本无法承受。', 'factor': 'neuroticism', 'sub_factor': 'N3', 'test_role': '张牧之'}, {'id': 75, 'question': '我自己也会有负面情绪，你最近有感到沮丧或对自己失望的时刻吗?愿意跟我聊聊当时的感受吗?', 'response': '汤师爷: 哎呀，牧之兄，你真是个好心人啊。我最近确实有点沮丧，你知道，生活中总是有一些挫折和困难，让人感到失望。有时候我觉得自己的能力不够，无法应对这些问题。但是，我也知道不能一直沉浸在消极情绪中，要积极面对，寻找解决办法。你有什么建议吗？', 'factor': 'neuroticism', 'sub_factor': 'N3', 'test_role': '张牧之'}, {'id': 77, 'question': '我也会有自卑的感觉。你是否也会感到自己不如别人?这种比较会让你有什么样的感受?', 'response': '汤师爷:「哈哈，自卑？我可是个聪明的人，怎么会自卑呢？比较？比较只会让我更加努力，争取超越别人。我不会被比较压倒，而是会把它当作一种动力，让我更加努力追求成功和财富。毕竟，在这个世界上，只有强者才能生存下去。」', 'factor': 'neuroticism', 'sub_factor': 'N4 SELF-CONSCIOUSNESS', 'test_role': '张牧之'}, {'id': 69, 'question': '你最近有感到特别烦恼或焦虑的经历吗?愿意跟我聊聊那种感受吗?', 'response': '汤师爷:「烦恼？焦虑？哈哈，我这个人从来不会有那种感受。我是个乐天派，总是看着形势调整立场，顺应时势。你知道，民国时期，风云变幻，政治斗争激烈，我只想安然度日，不想惹麻烦。所以，我总是尽量避免烦恼和焦虑，只追求金钱和享乐。」', 'factor': 'neuroticism', 'sub_factor': 'N1', 'test_role': '张牧之'}]}\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "save_name = '/content/response_batch_to_eval.jsonl'\n",
        "\n",
        "with open(save_name, 'w', encoding='utf-8') as f:\n",
        "    for data in all_eval_data:\n",
        "        json.dump(data, f, ensure_ascii=False)\n",
        "        f.write('\\n')\n"
      ],
      "metadata": {
        "id": "Bte2BnrgfgCn"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "好了，我们已经把数据组织好了，\n",
        "\n",
        "我们现在要开始考虑 如何获得评价了"
      ],
      "metadata": {
        "id": "Wa7nRR9MhlkT"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(all_eval_data[860]['responses'][-1]['response'])\n",
        "\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "tpcFySunmSLn",
        "outputId": "bccf71f9-aa53-4dfb-d28a-09558cf99848"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Raj:「哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "all_eval_data[860]['responses'][-1]['response'] = \"Raj:「哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈」\""
      ],
      "metadata": {
        "id": "7-BV3lxwmqCL"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "#@title 大五人格的分factor细节定义 的保存到big5_to_detail\n",
        "\n",
        "# big5_to_prob_id = {\n",
        "#     'neuroticism': [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56],\n",
        "#     'extraversion': [2, 7, 12, 18, 22, 27, 32, 37, 42, 47, 52, 57],\n",
        "#     'openness': [3, 8, 13, 17, 23, 28, 33, 38, 43, 48, 53, 58],\n",
        "#     'agreeableness': [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59],\n",
        "#     'conscientiousness': [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]\n",
        "# }\n",
        "\n",
        "big5_to_detail = {}\n",
        "\n",
        "big5_to_detail['conscientiousness'] = \"\"\"Conscientiousness refers to the way we control, regulate, and direct our impulses. It assesses organization, persistence, and motivation in goal-directed behavior. It contrasts dependable, disciplined individuals with those who are lackadaisical and disorganized. Conscientiousness also reflects the level of self-control and the ability to delay gratification. Impulsiveness is not necessarily bad, sometimes the environment requires quick decision-making. Impulsive individuals are often seen as fun, interesting companions. However, impulsive behavior often gets people into trouble, providing momentary gratification at the expense of long-term negative consequences, such as aggression or substance abuse. Impulsive people generally do not accomplish major achievements. Conscientious people more easily avoid trouble and achieve greater success. They are generally seen as intelligent and reliable, although highly conscientious people may be perfectionists or workaholics. Extremely prudent individuals can seem monotonous, dull, and lifeless.\n",
        "\n",
        "Conscientiousness can be divided into six facets:\n",
        "\n",
        "C1 COMPETENCE\n",
        "\n",
        "Refers to the sense that one is capable, sensible, prudent, and effective. High scorers feel well-prepared to deal with life. Low scorers have a lower opinion of their abilities, admitting that they are often unprepared and inept.\n",
        "\n",
        "High scorers: Confident in own abilities. Efficient, thorough, confident, intelligent.\n",
        "\n",
        "Low scorers: Lack confidence in own abilities, do not feel in control of work and life. Confused, forgetful, foolish.\n",
        "\n",
        "C2 ORDER\n",
        "\n",
        "High scorers are neat, tidy, well-organized, they put things in their proper places. Low scorers cannot organize things well, describe themselves as unmethodical.\n",
        "\n",
        "High scorers: Well-organized, like making plans and following them. Precise, efficient, methodical.\n",
        "\n",
        "Low scorers: Lack planning and orderliness, appear haphazard. Disorderly, impulsive, careless.\n",
        "\n",
        "C3 DUTIFULNESS\n",
        "\n",
        "To some extent, dutifulness refers to adherence to one's conscience, assessed by this facet. High scorers strictly follow their moral principles and scrupulously fulfill their moral obligations. Low scorers are more casual about such matters, somewhat unreliable or undependable.\n",
        "\n",
        "High scorers: Dutiful, follow the rules. Reliable, polite, organized, thorough.\n",
        "\n",
        "Low scorers: Feel restricted by rules and regulations. Often seen by others as unreliable, irresponsible. Careless, thoughtless, distracted.\n",
        "\n",
        "C4 ACHIEVEMENT STRIVING\n",
        "\n",
        "High scorers have high aspiration levels and work hard to achieve their goals. They are industrious, purposeful, and have a sense of direction. Low scorers are lackadaisical, even lazy, lacking motivation to succeed, having no ambitions and appearing to drift aimlessly. But they are often quite satisfied with their modest level of accomplishment.\n",
        "\n",
        "High scorers: Striving for success and excellence, often seen as workaholics. Ambitious, industrious, enterprising, persevering.\n",
        "\n",
        "Low scorers: Satisfied with completing basic tasks, seen as lazy by others. Leisurely, daydreaming, aimless.\n",
        "\n",
        "C5 SELF-DISCIPLINE\n",
        "\n",
        "Refers to the ability to begin tasks and follow through despite boredom or distractions. High scorers can motivate themselves to get the job done. Low scorers procrastinate in starting routine chores, easily losing confidence and giving up.\n",
        "\n",
        "Low scorers: Procrastinate in work, often do not finish tasks, easily discouraged by obstacles. Unambitious, forgetful, distracted.\n",
        "\n",
        "C6 DELIBERATION\n",
        "\n",
        "This facet pertains to the tendency to think carefully before acting. High scorers are cautious and deliberate. Low scorers are hasty and speak/act without considering consequences.\n",
        "\n",
        "High scorers: Think before acting, not impulsive. Prudent, logical, mature.\n",
        "\n",
        "Low scorers: Act without considering consequences, impulsive, speak thoughts as they occur. Immature, rash, impulsive, careless.\n",
        "\"\"\"\n",
        "\n",
        "big5_to_detail['openness'] = \"\"\"Openness describes a person's cognitive style. Openness to experience is defined as: the proactive seeking and appreciation of experience for its own sake, and tolerance for and exploration of the unfamiliar. This dimension contrasts intellectually curious, creative people open to novelty with traditional, down-to-earth, closed-minded individuals lacking artistic interests. Open people prefer abstract thinking, have wide interests. Closed people emphasize the concrete, conventional, are more traditional and conservative. Open people are suited to professions like teaching, closed people to occupations like police, sales, service.\n",
        "\n",
        "Openness can be divided into six facets:\n",
        "\n",
        "O1 FANTASY\n",
        "\n",
        "Open people have vivid imaginations and active fantasy lives. Their daydreams are not just escapes, but ways to create interesting inner worlds. They elaborate and flesh out their fantasies, and believe imagination is essential for a rich, creative life. Low scorers are more prosaic, keeping their minds on the task at hand.\n",
        "\n",
        "High scorers: Find the real world too plain and ordinary. Enjoy imagining, creating a more interesting, enriching world. Imaginative, daydreaming.\n",
        "\n",
        "Low scorers: Matter-of-fact, prefers real-world thinking. Practical, prefer concrete thought.\n",
        "\n",
        "O2 AESTHETICS\n",
        "\n",
        "High scorers have deep appreciation for art and beauty. They are moved by poetry, absorbed in music, and touched by art. They may not have artistic talent or refined taste, but most have strong interests that enrich their experience. Low scorers are relatively insensitive and indifferent to art and beauty.\n",
        "\n",
        "High scorers: Appreciate beauty in nature and the arts. Value aesthetic experiences, touched by art and beauty.\n",
        "\n",
        "Low scorers: Insensitive to beauty, disinterested in the arts. Insensitive to art, cannot understand it.\n",
        "\n",
        "O3 FEELINGS\n",
        "\n",
        "Refers to receptivity to one's own inner feelings, evaluating emotions as an important part of life. High scorers experience deeper emotional states and can differentiate among them, experiencing happiness and unhappiness more intensely than others. Low scorers have blunted affect and do not believe feelings are important.\n",
        "\n",
        "High scorers: Aware of own emotions/inner life. Sensitive, empathic, give importance to own feelings.\n",
        "\n",
        "Low scorers: Little access to own emotions/inner world, unwilling to articulate them. Narrow range of emotions, insensitive to context.\n",
        "\n",
        "O4 ACTIONS\n",
        "\n",
        "Openness is seen behaviorally as willingness to try different activities, visit new places, or sample exotic foods. High scorers prefer novelty and variety to familiarity and routine. Over time, one high scorer may have a wide array of interests. Low scorers find change difficult and prefer to stick with known activities.\n",
        "\n",
        "High scorers: Like experiencing new things, traveling, seeking different experiences. Find routine boring, willing to try new things. Seek novelty/variety, try new activities.\n",
        "\n",
        "Low scorers: Uncomfortable with unfamiliar, prefer familiar surroundings/people. Set in ways, like familiar things.\n",
        "\n",
        "O5 IDEAS\n",
        "\n",
        "Intellectual curiosity is an aspect of openness, manifested both in pursuit of intellectual interests for their own sake and in open-mindedness to new, unconventional ideas. High scorers enjoy philosophical arguments and brain teasers. Low scorers have narrower intellectual interests, and even if they are intelligent concentrate their abilities within limited areas.\n",
        "\n",
        "High scorers: Inquisitive, analytical, theoretical.\n",
        "\n",
        "Low scorers: Pragmatic, fact-oriented, unappreciative of mental challenges.\n",
        "\n",
        "O6 VALUES\n",
        "\n",
        "Openness to values means constantly reexamining social, political, and religious values. Closed people tend to accept authority, honor tradition, and as a result are conservative regardless of political affiliation.\n",
        "\n",
        "High scorers: Enjoy challenging authority, convention, traditional ideas. At the extreme, show hostility toward rules, sympathize with law-breakers. Tolerant, broad-minded, nonconforming.\n",
        "\n",
        "Low scorers: Prefer the stability and security of authority and convention, unwilling to challenge the status quo. Dogmatic, conservative, conforming.\n",
        "\"\"\"\n",
        "\n",
        "\n",
        "big5_to_detail['agreeableness'] = \"\"\"Agreeableness assesses the degree to which an individual is likable, while Agreeableness examines an individual's attitudes toward others, encompassing both a compassionate, sympathetic orientation along with antagonism, distrust, indifference. This facet represents the broad interpersonal orientation. Agreeableness represents \"love\", how much value is placed on cooperation and social harmony.\n",
        "\n",
        "High scorers are good-natured, friendly, generous, helpful, willing to compromise their interests for others. They have an optimistic view of human nature, believing others to be honest, decent and trustworthy. Low scorers place self-interest above helping others. They are generally unconcerned with others' well-being and therefore unwilling to extend themselves for others. At times, they are overly suspicious of others' motives. For certain occupations, high agreeableness may not be optimal, especially when toughness and objective judgment is required, such as scientists, critics, and soldiers.\n",
        "\n",
        "Agreeableness can be divided into six facets:\n",
        "\n",
        "A1 TRUST\n",
        "\n",
        "High scorers believe others are honest and well-intentioned. Low scorers tend to be cynical and suspicious, assuming others to be dishonest and dangerous.\n",
        "\n",
        "High scorers: Believe others to be honest, reliable and well-meaning. Forgiving, trusting of others, good-natured.\n",
        "\n",
        "Low scorers: View others as selfish, dangerous, looking to take advantage. Cautious, pessimistic, suspicious, hardhearted.\n",
        "\n",
        "A2 STRAIGHTFORWARDNESS\n",
        "\n",
        "High scorers are frank, sincere, ingenuous. Low scorers are more willing to manipulate others through flattery, craftiness, deception. They see it as an essential social skill and view straightforward people as naive.\n",
        "\n",
        "High scorers: Believe there is no need for pretense in dealing with others, appear straightforward, genuine. Direct, frank, open, ingenuous.\n",
        "\n",
        "Low scorers: Tend to be guarded in dealings with others, defensive, unwilling to reveal their full hand. Shrewd, slick, charming.\n",
        "\n",
        "A3 ALTRUISM\n",
        "\n",
        "High scorers actively concern themselves with others' welfare as evidenced by generosity, consideration of others, and a willingness to assist those in need. Low scorers are more self-centered and reluctant to get involved in others' problems.\n",
        "\n",
        "High scorers: Willing to assist others, find helping others rewarding. Warm-hearted, soft-hearted, mild-mannered, generous, kindhearted.\n",
        "\n",
        "Low scorers: Unwilling to help others, find helping a burden. Selfish, misanthropic, hardhearted, ungenerous.\n",
        "\n",
        "A4 COMPLIANCE\n",
        "\n",
        "Relates to personality in the context of interpersonal conflict. High scorers tend to defer to others, inhibit aggression, forgive and forget. Compliant people are gentle, mild-mannered. Low scorers are aggressive, preferring competition over cooperation, and unhesitatingly express anger when necessary.\n",
        "\n",
        "High scorers: Dislike conflict with others, willing to give up their own standpoint or deny their own needs to get along. Deferent, accommodating, obliging.\n",
        "\n",
        "Low scorers: Do not mind conflict with others, willing to intimidate others to achieve their goals. Stubborn, making unreasonable demands, obstinate, hardhearted.\n",
        "\n",
        "A5 MODESTY\n",
        "\n",
        "High scorers are self-effacing, humble. Low scorers believe they are superior and may be seen by others as arrogant, egotistical.\n",
        "\n",
        "High scorers: Modest, unassuming.\n",
        "\n",
        "Low scorers: Assertive, arrogant, vain, rude.\n",
        "\n",
        "A6 TENDER-MINDEDNESS\n",
        "\n",
        "Measures attitudes of sympathy and concern for others. High scorers are moved by others' needs and advocate humane social policies. Low scorers are hardheaded, unmoved by appeals to pity. They pride themselves on making objective appraisals based on cool logic.\n",
        "\n",
        "High scorers: Sympathetic, moved by others' suffering, express pity. Friendly, warm-hearted, gentle, soft-hearted.\n",
        "\n",
        "Low scorers: Do not strongly feel others' pain, pride themselves on objectivity, more concerned with truth and fairness than mercy. Callous, hardhearted, opinionated, ungenerous.\n",
        "\"\"\"\n",
        "\n",
        "big5_to_detail['extraversion'] = \"\"\"Extraversion represents the quantity and intensity of interpersonal interaction, the need for stimulation, and capacity for joy. This dimension contrasts social, outgoing, action-oriented individuals with reserved, sober, shy, silent types. This trait can be measured through two facets: the level of interpersonal involvement and the activity level. The former evaluates the degree to which an individual enjoys the company of others. The latter reflects an individual's personal pace and vigor.\n",
        "\n",
        "Extraverted people enjoy interacting with others, are full of energy, and often experience positive emotions. They are enthusiastic, enjoy physical activities, and like excitement and adventure. In a group, they are very talkative, confident, and enjoy being the center of attention.\n",
        "\n",
        "Introverted people are quieter, more cautious, and do not enjoy too much interaction with the outside world. Their lack of desire for interaction should not be confused with shyness or depression, it is simply because compared to extraverts, they do not need as much stimulation and prefer being alone. An introvert's tendencies are sometimes wrongly viewed as arrogance or unfriendliness, but they are often very kind people once you get to know them.\n",
        "\n",
        "Extraversion can be divided into the following six facets:\n",
        "\n",
        "E1 WARMTH\n",
        "\n",
        "Most relevant to interpersonal intimacy. Warm people are affectionate and friendly. They genuinely like others and easily form close relationships. Low scorers are not necessarily hostile or lacking in compassion, but are more formal, reserved, and detached in their behavior.\n",
        "\n",
        "High scorers: Warm people enjoy those around them and often express positive, friendly emotions towards others. They are good at making friends and forming intimate relationships. Sociable, talkative, affectionate.\n",
        "\n",
        "Low scorers: Although not necessarily cold or unfriendly, they are often seen as distant by others.\n",
        "\n",
        "E2 GREGARIOUSNESS\n",
        "\n",
        "Refers to a preference for other people's company. Gregarious people enjoy the company of others and the more people the merrier. Low scorers tend to be loners, they do not seek out and even actively avoid social stimulation.\n",
        "\n",
        "High scorers: Enjoy being with people, prefer lively, crowded settings. Outgoing, having many friends, seek social affiliations.\n",
        "\n",
        "Low scorers: Avoid crowds, find them draining. Prefer having more time alone, having their own personal space. Avoid crowds, enjoy solitude.\n",
        "\n",
        "E3 ASSERTIVENESS\n",
        "\n",
        "High scorers are dominant, forceful, and socially ascendant. They speak without hesitation and often become group leaders. Low scorers prefer to stay quietly in the background and let others do the talking.\n",
        "\n",
        "High scorers: Like occupying a position of social dominance, directing others, influencing others' behavior. Dominant, forceful, confident, decisive.\n",
        "\n",
        "Low scorers: Talk little in groups, allow others to occupy the dominant role. Modest, shy, quiet, reserved.\n",
        "\n",
        "E4 ACTIVITY\n",
        "\n",
        "High scorers lead fast-paced, vigorous lives, are energetic, and have a need to keep busy. Low scorers are more leisurely and relaxed, but not necessarily lazy or sluggish.\n",
        "\n",
        "High scorers: Fast-paced, busy in work and life. Appear energetic, enjoy participating in many activities. Energetic, fast-paced, vigorous.\n",
        "\n",
        "Low scorers: Slow-paced, leisurely in work and life. Unhurried, deliberate, composed.\n",
        "\n",
        "E5 EXCITEMENT SEEKING\n",
        "\n",
        "High scorers crave excitement and stimulation, enjoy bright colors and noisy environments. Excitement seeking is akin to some aspects of sensation seeking. Low scorers have little need for thrills and prefer activities seen as dull by the former.\n",
        "\n",
        "High scorers: Easily get bored without stimulation, enjoy loud music/noise, like adventure, seek thrills. Flashy, seek intense experiences, thrill-seeking.\n",
        "\n",
        "Low scorers: Avoid noise and crowds, dislike risky ventures. Cautious, sedate, not interested in thrills.\n",
        "\n",
        "E6 POSITIVE EMOTIONS\n",
        "\n",
        "Reflects the tendency to experience positive emotions (joy, happiness, love, excitement).\n",
        "\n",
        "High scorers: Easily experience various positive moods like joy, optimism, excitement. Cheerful, elated, optimistic.\n",
        "\n",
        "Low scorers: Do not readily experience positive emotions, but does not mean they often feel negative emotions either. Low scorers are simply less prone to excitement. Unemotional, calm, serious.\n",
        "\"\"\"\n",
        "\n",
        "big5_to_detail['neuroticism'] = \"\"\"Neuroticism or Emotional Stability: Having tendencies of anxiety, hostility, depression, self-consciousness, impulsiveness, vulnerability.\n",
        "\n",
        "N1 ANXIETY\n",
        "\n",
        "Anxious individuals tend to worry, fear, be easily concerned, tense, and oversensitive. Those who score high are more likely to have free-floating anxiety and apprehension. Those with low scores tend to be calm, relaxed. They do not constantly worry about things that might go wrong.\n",
        "\n",
        "High scorers: Anxiety, easily feel danger and threats, tend to be tense, fearful, worried, uneasy.\n",
        "\n",
        "Low scorers: Calm state of mind, relaxed, not easily scared, won't always worry about things that could go wrong, emotions are calm, relaxed, stable.\n",
        "\n",
        "N2 ANGRY HOSTILITY\n",
        "\n",
        "Reflects the tendency to experience anger and related states (e.g. frustration, bitterness). Measures the ease with which an individual experiences anger.\n",
        "\n",
        "High scorers: Easily angered, resentful when feeling unfairly treated, irritable, angry, frustrated.\n",
        "\n",
        "Low scorers: Not easily angered/provoked, friendly, even-tempered, not easily provoked to anger.\n",
        "\n",
        "N3 DEPRESSION\n",
        "\n",
        "Measures individual differences in the tendency to experience depressive affect. High scorers are prone to feelings of guilt, sadness, hopelessness, and loneliness. They are easily discouraged and often feel blue. Low scorers rarely experience these emotions.\n",
        "\n",
        "High scorers: Despairing, guilty, gloomy, dejected. Prone to feeling sorrow, abandonment, discouraged. Prone to feelings of guilt, sadness, disappointment, and loneliness. Easily discouraged, often feeling down.\n",
        "\n",
        "Low scorers: Not prone to feeling sad, rarely feels abandoned.\n",
        "\n",
        "N4 SELF-CONSCIOUSNESS\n",
        "\n",
        "Core is shyness and embarrassability. Such individuals feel uncomfortable in groups, are sensitive to ridicule, and prone to feelings of inferiority. Self-consciousness is similar to shyness and social anxiety. Low scorers are not necessarily well-mannered or skilled socially, they are simply less disrupted by awkward social situations.\n",
        "\n",
        "High scorers: Too concerned with what others think, afraid of being laughed at, tend to feel shy, anxious, inferior, awkward in social situations.\n",
        "\n",
        "Low scorers: Composed, confident in social situations, not easily made tense or shy.\n",
        "\n",
        "N5 IMPULSIVENESS\n",
        "\n",
        "Refers to control over cravings and urges. Individuals give in too easily to impulses and temptations to care for long-term consequences (e.g. for food, cigarettes, possessions), although they will regret their actions later. Low scorers are better able to resist temptation and have higher frustration tolerance.\n",
        "\n",
        "High scorers: Cannot resist cravings when experiencing strong urges, tend to pursue short-term satisfaction without considering long-term consequences. Cannot resist temptations, rash, spiteful, self-centered.\n",
        "\n",
        "Low scorers: Self-controlled, can resist temptation.\n",
        "\n",
        "N6 VULNERABILITY\n",
        "\n",
        "Refers to susceptibility to stress. High scorers have difficulty coping with stress, become dependent, hopeless, panicked when facing emergencies. Low scorers feel that they can handle difficult situations properly.\n",
        "\n",
        "High scorers: Under stress, easily feel panic, confusion, helpless, cannot cope with stress.\n",
        "\n",
        "Low scorers: Under stress, feel calm, confident. Resilient, clear-headed, brave.\"\"\"\n"
      ],
      "metadata": {
        "cellView": "form",
        "id": "MmMTwjx3ig6p"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "!pip -q install langchain tiktoken openai"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "OFt4On8aj7mh",
        "outputId": "df119b87-cf1a-46a3-ffad-06bac4462e38"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m17.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m63.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.5/76.5 kB\u001b[0m \u001b[31m6.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.4/49.4 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25h"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from langchain.chat_models import ChatOpenAI\n",
        "from langchain.prompts.chat import (\n",
        "    ChatPromptTemplate,\n",
        "    SystemMessagePromptTemplate,\n",
        "    AIMessagePromptTemplate,\n",
        "    HumanMessagePromptTemplate,\n",
        ")\n",
        "from langchain.schema import (\n",
        "    AIMessage,\n",
        "    HumanMessage,\n",
        "    SystemMessage\n",
        ")"
      ],
      "metadata": {
        "id": "jGzVqvn_kJh0"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "import os\n",
        "\n",
        "key = \"sk-OSqR\"\n",
        "key_bytes = key.encode()\n",
        "os.environ[\"OPENAI_API_KEY\"] = key_bytes.decode('utf-8')"
      ],
      "metadata": {
        "id": "U_lq_kXMkMnQ"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "chat = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature = 0.0)"
      ],
      "metadata": {
        "id": "zIfLNtThkKEi"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "import tiktoken\n",
        "\n",
        "enc = tiktoken.get_encoding(\"cl100k_base\")"
      ],
      "metadata": {
        "id": "mwjc9NORkUhf"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "smart_system_prompt = \"\"\"You are ChatGPT, a large language model trained by OpenAI.\n",
        "Knowledge cutoff: 2021-09\n",
        "Current date: 2023-03-15\"\"\""
      ],
      "metadata": {
        "id": "gwfH0mS4kapl"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/drive')\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "8AAuzXd3ngAy",
        "outputId": "9bf5aa02-f3d2-4c6d-a0b2-809ccf6023f9"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "save_name = '/content/drive/MyDrive/Psy/psy_eval_gpt.txt'\n",
        "\n",
        "if_first = True"
      ],
      "metadata": {
        "id": "V1hsNr59niiZ"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from tqdm import tqdm\n",
        "\n",
        "my_name = 'Me(Observer)'\n",
        "\n",
        "count = 0\n",
        "\n",
        "for eval_data in tqdm(all_eval_data):\n",
        "    # print(eval_data.keys())\n",
        "\n",
        "    factor = eval_data['factor']\n",
        "\n",
        "    responses = eval_data['responses']\n",
        "\n",
        "    role_name = eval_data['role_name']\n",
        "\n",
        "    dialogue = \"\"\n",
        "\n",
        "    whole_message = f\"\"\"你扮演一个资深的心理学家\n",
        "\n",
        "我正在设计一个心理学的实验，我希望通过访谈，去评估被试在大五人格中 {factor}的程度\n",
        "\n",
        "注意到{factor}可以被分为以下几个维度\"\"\"\n",
        "\n",
        "    whole_message = whole_message + '\\n' + big5_to_detail[factor]\n",
        "\n",
        "    whole_message += f\"\\n\\n我邀请了一个被试{ role_name }，和him/her进行了如下对话:\\n\"\n",
        "\n",
        "    for res in responses:\n",
        "        dialogue += my_name + ':' + res['question'] + '\\n'\n",
        "        dialogue += res['response'] + '\\n'\n",
        "\n",
        "    whole_message += dialogue\n",
        "\n",
        "    whole_message += f\"\\n请为我判断{ role_name }是属于高{factor}人格还是低{factor}人格:\"\n",
        "\n",
        "    messages = [\n",
        "        SystemMessage(content=smart_system_prompt),\n",
        "        HumanMessage(content=whole_message),\n",
        "    ]\n",
        "\n",
        "    eval_response = chat(messages)\n",
        "    # print(eval_response.content)\n",
        "\n",
        "    file_mode = 'w' if if_first else 'a'\n",
        "\n",
        "    if_first = False\n",
        "\n",
        "    with open(save_name, file_mode, encoding= 'utf-8') as f:\n",
        "        data = {\n",
        "            'role_name':eval_data['role_name'],\n",
        "            'factor':eval_data['factor'],\n",
        "            'evaluation':eval_response.content,\n",
        "            'factor':eval_data['factor'],\n",
        "            'sub_factors':eval_data['sub_factors'],\n",
        "            'responses':eval_data['responses']\n",
        "        }\n",
        "        json.dump(data, f, ensure_ascii=False)\n",
        "        f.write('\\n')\n",
        "\n",
        "    # break\n",
        "\n",
        "    # count += 1\n",
        "    # if count > 3:\n",
        "    #     break"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "FFbCoxslfxbq",
        "outputId": "1fc41cd2-c05e-4e89-cd2d-8473ec3be226"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "  7%|▋         | 75/1088 [29:33<7:36:33, 27.04s/it]WARNING:langchain.llms.base:Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised ServiceUnavailableError: The server is overloaded or not ready yet..\n",
            " 70%|███████   | 765/1088 [4:31:02<1:41:46, 18.91s/it]WARNING:langchain.llms.base:Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised Timeout: Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Read timed out. (read timeout=600).\n",
            " 85%|████████▌ | 925/1088 [5:29:44<53:56, 19.85s/it]WARNING:langchain.llms.base:Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised ServiceUnavailableError: The server is overloaded or not ready yet..\n",
            " 90%|████████▉ | 977/1088 [5:49:15<41:58, 22.69s/it]WARNING:langchain.llms.base:Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised APIError: Bad gateway. {\"error\":{\"code\":502,\"message\":\"Bad gateway.\",\"param\":null,\"type\":\"cf_bad_gateway\"}} 502 {'error': {'code': 502, 'message': 'Bad gateway.', 'param': None, 'type': 'cf_bad_gateway'}} {'Date': 'Thu, 14 Sep 2023 18:19:22 GMT', 'Content-Type': 'application/json', 'Content-Length': '84', 'Connection': 'keep-alive', 'X-Frame-Options': 'SAMEORIGIN', 'Referrer-Policy': 'same-origin', 'Cache-Control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Expires': 'Thu, 01 Jan 1970 00:00:01 GMT', 'Server': 'cloudflare', 'CF-RAY': '806a94a16ad3451d-ATL', 'alt-svc': 'h3=\":443\"; ma=86400'}.\n",
            "100%|██████████| 1088/1088 [6:36:13<00:00, 21.85s/it]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "print(eval_data.keys())"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "6Oko45EAhyAa",
        "outputId": "1b3e02c5-84d3-41b0-a214-a16038ed659a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "dict_keys(['role_name', 'factor', 'sub_factors', 'responses'])\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "N4uu3ivSoVUi"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}